bitkeeper revision 1.1159.142.2 (41849fadYlUYMwSy6tcq8Y-Yi8NMZA)
authorkaf24@freefall.cl.cam.ac.uk <kaf24@freefall.cl.cam.ac.uk>
Sun, 31 Oct 2004 08:17:49 +0000 (08:17 +0000)
committerkaf24@freefall.cl.cam.ac.uk <kaf24@freefall.cl.cam.ac.uk>
Sun, 31 Oct 2004 08:17:49 +0000 (08:17 +0000)
Clean up libxc by allowing direct use of Xen headers from userland:
 #include <xen/...>

13 files changed:
BitKeeper/etc/ignore
tools/libxc/Makefile
tools/libxc/xc.h
tools/libxc/xc_domain.c
tools/libxc/xc_evtchn.c
tools/libxc/xc_linux_save.c
tools/libxc/xc_misc.c
tools/libxc/xc_private.h
tools/misc/Makefile
tools/xentrace/Makefile
tools/xentrace/xentrace.c
tools/xfrd/Makefile
xen/Makefile

index d039d56f506d9df74b982153f9266a6f028c6e5a..607dc5adf539cebb94479746e69480884467232f 100644 (file)
@@ -32,6 +32,7 @@ patches/*
 tools/*/build/lib*/*.py
 tools/balloon/balloon
 tools/check/.*
+tools/libxc/xen
 tools/misc/miniterm/miniterm
 tools/misc/xen_cpuperf
 tools/web-shutdown.tap
index 1678a1a448f288653c2bd4db1961d2fec9cd5feb..18c09c2f6cefb35d0c9f8c2136a6ee223bf9f611 100644 (file)
@@ -8,9 +8,6 @@ CC       = gcc
 XEN_ROOT = ../..
 include $(XEN_ROOT)/tools/Make.defs
 
-vpath %.h      $(XEN_HYPERVISOR_IFS)
-INCLUDES += -I $(XEN_HYPERVISOR_IFS)
-
 vpath %h       $(XEN_LINUX_INCLUDE)
 INCLUDES += -I $(XEN_LINUX_INCLUDE)
 
@@ -44,7 +41,7 @@ OBJS     = $(patsubst %.c,%.o,$(SRCS))
 
 LIB      = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)
 
-all: check-for-zlib $(LIB)
+all: check-for-zlib mk-symlinks $(LIB)
 
 check-for-zlib:
        @if [ ! -e /usr/include/zlib.h ]; then \
@@ -54,6 +51,9 @@ check-for-zlib:
        false; \
        fi
 
+mk-symlinks:
+       ln -sf $(XEN_HYPERVISOR_IFS) xen
+
 install: all
        mkdir -p $(prefix)/usr/lib
        mkdir -p $(prefix)/usr/include
@@ -61,9 +61,7 @@ install: all
        install -m0644 xc.h $(prefix)/usr/include
 
 clean:
-       $(RM) *.a *.so *.o *.rpm $(LIB)
-       $(RM) *~
-       $(RM) $(DEPS)
+       $(RM) *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen
 
 rpm: all
        rm -rf staging
index 027d76711fd8b205c730fd9304954c84d898ab1b..4f01a8d9b45d0a3d08abffc49d59b6f0537447df 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * A library for low-level access to the Xen control interfaces.
  * 
- * Copyright (c) 2003, K A Fraser.
+ * Copyright (c) 2003-2004, K A Fraser.
  */
 
 #ifndef __XC_H__
@@ -18,6 +18,12 @@ typedef signed short       s16;
 typedef signed long        s32;
 typedef signed long long   s64;
 
+#include "xen/hypervisor-if.h"
+#include "xen/dom0_ops.h"
+#include "xen/event_channel.h"
+#include "xen/sched_ctl.h"
+#include "xen/io/domain_controller.h"
+
 /* Obtain or relinquish a handle on the 'xc' library. */
 int xc_interface_open(void);
 int xc_interface_close(int xc_handle);
@@ -34,14 +40,7 @@ typedef struct {
     unsigned long max_memkb;
 } xc_dominfo_t;
 
-typedef struct xc_shadow_control_stats_st
-{
-    unsigned long fault_count;
-    unsigned long dirty_count;
-    unsigned long dirty_net_count;     
-    unsigned long dirty_block_count;     
-} xc_shadow_control_stats_t;
-
+typedef dom0_getdomaininfo_t xc_domaininfo_t;
 int xc_domain_create(int xc_handle, 
                      unsigned int mem_kb, 
                      int cpu,
@@ -60,10 +59,18 @@ int xc_domain_getinfo(int xc_handle,
                       u32 first_domid, 
                       unsigned int max_doms,
                       xc_dominfo_t *info);
+int xc_domain_getfullinfo(int xc_handle,
+                          u32 domid,
+                          xc_domaininfo_t *info,
+                          full_execution_context_t *ctxt);
 int xc_domain_setcpuweight(int xc_handle,
                            u32 domid,
                            float weight);
+long long xc_domain_get_cpu_usage(int xc_handle,
+                                  domid_t domid);
 
+
+typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
 int xc_shadow_control(int xc_handle,
                       u32 domid, 
                       unsigned int sop,
@@ -125,27 +132,7 @@ int xc_rrobin_global_set(int xc_handle, u64 slice);
 
 int xc_rrobin_global_get(int xc_handle, u64 *slice);
 
-#define DOMID_SELF              (0x7FF0U)
-#define DOMID_IO                (0x7FF1U)
-#define DOMID_XEN               (0x7FF2U)
-
-typedef struct {
-#define EVTCHNSTAT_closed       0  /* Chennel is not in use.                 */
-#define EVTCHNSTAT_unbound      1  /* Channel is not bound to a source.      */
-#define EVTCHNSTAT_interdomain  2  /* Channel is connected to remote domain. */
-#define EVTCHNSTAT_pirq         3  /* Channel is bound to a phys IRQ line.   */
-#define EVTCHNSTAT_virq         4  /* Channel is bound to a virtual IRQ line */
-    int status;
-    union {
-        struct {
-            u32 dom;
-            int port;
-        } interdomain;
-        int pirq;
-        int virq;
-    } u;
-} xc_evtchn_status_t;
-
+typedef evtchn_status_t xc_evtchn_status_t;
 int xc_evtchn_alloc_unbound(int xc_handle,
                             u32 dom,
                             int *port);
@@ -179,14 +166,7 @@ int xc_readconsolering(int xc_handle,
                        unsigned int max_chars, 
                        int clear);
 
-typedef struct {
-    int ht_per_core;
-    int cores;
-    unsigned long total_pages;
-    unsigned long free_pages;
-    unsigned long cpu_khz;
-} xc_physinfo_t;
-
+typedef dom0_physinfo_t xc_physinfo_t;
 int xc_physinfo(int xc_handle,
                 xc_physinfo_t *info);
 
index 958d85a69ef848fda339b5ff178fc56f70a8ed8b..67168910e9f379245b789078bd6a172e9776b1e0 100644 (file)
@@ -120,16 +120,21 @@ int xc_domain_getinfo(int xc_handle,
 
 int xc_domain_getfullinfo(int xc_handle,
                           u32 domid,
-                          dom0_op_t *op,
-                          full_execution_context_t *ctxt )
+                          xc_domaininfo_t *info,
+                          full_execution_context_t *ctxt)
 {
     int rc;
-    op->cmd = DOM0_GETDOMAININFO;
-    op->u.getdomaininfo.domain = (domid_t)domid;
-    op->u.getdomaininfo.ctxt = ctxt;
+    dom0_op_t op;
+
+    op.cmd = DOM0_GETDOMAININFO;
+    op.u.getdomaininfo.domain = (domid_t)domid;
+    op.u.getdomaininfo.ctxt = ctxt;
+
+    rc = do_dom0_op(xc_handle, &op);
+
+    memcpy(info, &op.u.getdomaininfo, sizeof(*info));
 
-    rc = do_dom0_op(xc_handle, op);
-    if ( ((u16)op->u.getdomaininfo.domain != domid) && rc > 0 )
+    if ( ((u16)op.u.getdomaininfo.domain != domid) && rc > 0 )
         return -ESRCH;
     else
         return rc;
index 2f78ef79365eac42f41b1cedeeeccad551fa439d..9371e61261ae00ce9fb9168a3e740c52b726339c 100644 (file)
@@ -134,21 +134,7 @@ int xc_evtchn_status(int xc_handle,
     op.u.status.port = port;
    
     if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
-    {
-        switch ( status->status = op.u.status.status )
-        {
-        case EVTCHNSTAT_interdomain:
-            status->u.interdomain.dom  = (u16)op.u.status.u.interdomain.dom;
-            status->u.interdomain.port = op.u.status.u.interdomain.port;
-            break;
-        case EVTCHNSTAT_pirq:
-            status->u.pirq = op.u.status.u.pirq;
-            break;
-        case EVTCHNSTAT_virq:
-            status->u.virq = op.u.status.u.virq;
-            break;
-        }
-    }
+        memcpy(status, &op.u.status, sizeof(*status));
     
     return rc;
 }
index 7e0ab5c502ac2069931b7aaf7bfab8fad5e7448c..e9f4259494f4b47f835e2bf8a9a3b5540ef3e5e5 100644 (file)
@@ -319,9 +319,9 @@ static int analysis_phase( int xc_handle, u32 domid,
 }
 
 
-int suspend_and_state( int xc_handle, XcIOContext *ioctxt,                   
-                      dom0_op_t *op,
-                      full_execution_context_t *ctxt )
+int suspend_and_state(int xc_handle, XcIOContext *ioctxt,                    
+                      xc_domaininfo_t *info,
+                      full_execution_context_t *ctxt)
 {
     int i=0;
     
@@ -329,26 +329,26 @@ int suspend_and_state( int xc_handle, XcIOContext *ioctxt,
 
 retry:
 
-    if ( xc_domain_getfullinfo( xc_handle, ioctxt->domain, op, ctxt) )
+    if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, info, ctxt) )
     {
        xcio_error(ioctxt, "Could not get full domain info");
        return -1;
     }
 
-    if ( (op->u.getdomaininfo.flags & 
-         ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
-        == ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
+    if ( (info->flags & 
+          (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT))) ==
+         (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT)) )
     {
        return 0; // success
     }
 
-    if ( op->u.getdomaininfo.flags & DOMFLAGS_PAUSED )
+    if ( info->flags & DOMFLAGS_PAUSED )
     {
        // try unpausing domain, wait, and retest       
        xc_domain_unpause( xc_handle, ioctxt->domain );
 
        xcio_error(ioctxt, "Domain was paused. Wait and re-test. (%lx)",
-                  op->u.getdomaininfo.flags);
+                  info->flags);
        usleep(10000);  // 10ms
 
        goto retry;
@@ -358,20 +358,21 @@ retry:
     if( ++i < 100 )
     {
        xcio_error(ioctxt, "Retry suspend domain (%lx)",
-                  op->u.getdomaininfo.flags);
+                  info->flags);
        usleep(10000);  // 10ms 
        goto retry;
     }
 
     xcio_error(ioctxt, "Unable to suspend domain. (%lx)",
-              op->u.getdomaininfo.flags);
+              info->flags);
 
     return -1;
 }
 
 int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
 {
-    dom0_op_t op;
+    xc_domaininfo_t info;
+
     int rc = 1, i, j, k, last_iter, iter = 0;
     unsigned long mfn;
     u32 domid = ioctxt->domain;
@@ -441,12 +442,12 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
         return 1;
     }
 
-    if ( xc_domain_getfullinfo( xc_handle, domid, &op, &ctxt) )
+    if ( xc_domain_getfullinfo( xc_handle, domid, &info, &ctxt) )
     {
         xcio_error(ioctxt, "Could not get full domain info");
         goto out;
     }
-    shared_info_frame = op.u.getdomaininfo.shared_info_frame;
+    shared_info_frame = info.shared_info_frame;
 
     /* A cheesy test to see whether the domain contains valid state. */
     if ( ctxt.pt_base == 0 ){
@@ -454,7 +455,7 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
         goto out;
     }
     
-    nr_pfns = op.u.getdomaininfo.max_pages; 
+    nr_pfns = info.max_pages; 
 
     /* cheesy sanity check */
     if ( nr_pfns > 1024*1024 ){
@@ -536,10 +537,10 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
 
         last_iter = 1;
 
-       if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
+       if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
        {
            xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
-                      op.u.getdomaininfo.flags);
+                      info.flags);
            goto out;
        }
 
@@ -900,17 +901,17 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
                 DPRINTF("Start last iteration\n");
                 last_iter = 1;
 
-               if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
+               if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
                {
                    xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
-                              op.u.getdomaininfo.flags);
+                              info.flags);
                    goto out;
                }
 
                xcio_info(ioctxt,
                           "SUSPEND flags %08lx shinfo %08lx eip %08lx "
-                          "esi %08lx\n", op.u.getdomaininfo.flags,
-                          op.u.getdomaininfo.shared_info_frame,
+                          "esi %08lx\n",info.flags,
+                          info.shared_info_frame,
                           ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
             } 
 
index 0019ffe96bfa402ca247f10e5b6f21525eae6447..e8ea18c5ff388c8253eb660d1f8dce1e82b9285d 100644 (file)
@@ -52,18 +52,14 @@ int xc_physinfo(int xc_handle,
 {
     int ret;
     dom0_op_t op;
-    dom0_physinfo_t *got_info = &op.u.physinfo;
     
     op.cmd = DOM0_PHYSINFO;
     op.interface_version = DOM0_INTERFACE_VERSION;
 
-    if((ret = do_dom0_op(xc_handle, &op))) return ret;
+    if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
+        return ret;
 
-    put_info->ht_per_core = got_info->ht_per_core;
-    put_info->cores       = got_info->cores;
-    put_info->total_pages = got_info->total_pages;
-    put_info->free_pages  = got_info->free_pages;
-    put_info->cpu_khz     = got_info->cpu_khz;
+    memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
 
     return 0;
 }
index 3da14a16a846ef6d6693c81e75caf4a150225b85..8fd4559886b089b1c0334d872adb213a400c0293 100644 (file)
 
 #include "xc.h"
 
-/* from xen/include/hypervisor-ifs */
-#include <hypervisor-if.h>
-#include <dom0_ops.h>
-#include <event_channel.h>
-#include <sched_ctl.h>
-#include <io/domain_controller.h>
-
 #include <asm-xen/proc_cmd.h>
 
 
@@ -193,15 +186,8 @@ typedef struct mfn_mapper {
     
 } mfn_mapper_t;
 
-long long  xc_domain_get_cpu_usage( int xc_handle, domid_t domid );
-
 #include "xc_io.h"
 
-int xc_domain_getfullinfo(int xc_handle,
-                          u32 domid,
-                          dom0_op_t *op,
-                          full_execution_context_t *ctxt );
-
 unsigned long xc_get_m2p_start_mfn ( int xc_handle );
 
 #endif /* __XC_PRIVATE_H__ */
index 741f32976c244736aae282202f099d60517d919f..0dc13c4b50d8e05c043d905de9fe229c5b89fce3 100644 (file)
@@ -5,7 +5,6 @@ include $(XEN_ROOT)/tools/Make.defs
 CC         = gcc
 CFLAGS     = -Wall -O3 
 
-INCLUDES += -I $(XEN_HYPERVISOR_IFS)
 INCLUDES += -I $(XEN_LINUX_INCLUDE)
 INCLUDES += -I $(XEN_XC)
 INCLUDES += -I $(XEN_LIBXC)
index de5350e3c21616c347912d963e9cccbce1a224f7..7759b90f863df216af7c2acef45ab1d1f39ef124 100644 (file)
@@ -5,7 +5,6 @@ include $(XEN_ROOT)/tools/Make.defs
 CC       = gcc
 CFLAGS   = -Wall -Werror -O3
 
-CFLAGS  += -I $(XEN_HYPERVISOR_IFS)
 CFLAGS  += -I $(XEN_LINUX_INCLUDE)
 CFLAGS  += -I $(XEN_XC)
 CFLAGS  += -I $(XEN_LIBXC)
index 2df1ed9462b168a3c9f1671edb5a67746f63c33d..351ecd71a8563a5301724b6af27eb6cd4651815b 100644 (file)
@@ -22,9 +22,7 @@
 #include <signal.h>
 
 #include "xc_private.h"
-
-/* from xen/include/hypervisor-ifs */
-#include <trace.h>
+#include <xen/trace.h>
 
 extern FILE *stderr;
 
index 5824960ac95edb10e343b1a5683189023f40b878..9b8d9bc108f2ce54fb91ef98f69ecf260c4a6d45 100644 (file)
@@ -9,9 +9,6 @@ include $(XEN_ROOT)/tools/Make.defs
 
 XFRD_INSTALL_DIR = /usr/sbin
 
-vpath %.h      $(XEN_HYPERVISOR_IFS)
-INCLUDES += -I $(XEN_HYPERVISOR_IFS)
-
 vpath %h       $(XEN_LINUX_INCLUDE)
 INCLUDES += -I $(XEN_LINUX_INCLUDE)
 
index deda9176921e4fe70ecb2f44493f77ba4e9de319..ae43aa188c61c373af3f5b3313cd87d622306092 100644 (file)
@@ -22,6 +22,10 @@ install: $(TARGET)
        mkdir -p $(prefix)/boot
        install -m0644 $(TARGET).gz $(prefix)/boot
        install -m0644 $(TARGET)-syms $(prefix)/boot
+       mkdir -p $(prefix)/usr/include/xen/io
+       install -m0644 include/hypervisor-ifs/*.h $(prefix)/usr/include/xen
+       install -m0644 include/hypervisor-ifs/io/*.h $(prefix)/usr/include/xen/io
+       install -m0644 include/hypervisor-ifs/COPYING $(prefix)/usr/include/xen
 
 dist: $(TARGET)
        $(MAKE) prefix=`pwd`/../install dist=yes install